package com.itheima.service;

import com.itheima.domain.SmsCode;
import com.itheima.utils.CreateIdentify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author tongchen
 * @create 2022-12-22 11:43
 */

@Service
public class MessageServiceImpl implements MesService{
    @Autowired
    CreateIdentify createIdentify;
    @Override
    @CachePut(value = "smsCode",key = "#tele")
    public String sendMessage(String tele) {
        return createIdentify.createIdentify(tele);
    }

    @Override
    public boolean checkMessage(SmsCode smsCode) {
        String code = smsCode.getCode();
        String msg = createIdentify.getMsg(smsCode.getTele());
        return code.equals(msg);
    }
}
